﻿@model FieldControlViewModel
@{
	string dataVal = string.Empty;
	string dataValMsg = string.Empty;
	if (Model.EnableNull)
	{
		dataVal += " data-val-required=\"不能为空\" ";
	}
	if (!string.IsNullOrEmpty(dataVal))
	{
		dataVal += " data-val=\"true\" ";
		dataValMsg = " data-valmsg-for=\"" + Model.Prefix + Model.FieldName + "\" data-valmsg-replace=\"true\"";
	}
}
<div class="layui-input-inline" style="width: 100px;">
	<input type="text" class="layui-input" name="@Model.Prefix@Model.FieldName" id="@Model.Prefix@Model.FieldName" value="@Model.FieldValue" @Html.Raw(dataVal) placeholder="请选择颜色" />
</div>
<div class="layui-inline" style="left: -4px;">
	<div id="ctl@{@Model.Prefix@Model.FieldName}"></div>
</div>
<div class="layui-input-inline layui-input-company">
	<span class="layui-bg-green">@Model.Description</span>
	<span style="color:red;" @Html.Raw(dataValMsg)></span>
</div>
<script type="text/javascript">
	jQuery(function () {
		layui.use('colorpicker', function () {
			var colorpicker = layui.colorpicker;
			colorpicker.render({
				elem: '#ctl@{@Model.Prefix@Model.FieldName}'
				, color: '@Model.FieldValue'
				, change: function (color) {
					$('#@{@Model.Prefix@Model.FieldName}').val(color);
				}
				, done: function (color) {
					$('#@{@Model.Prefix@Model.FieldName}').val(color);
				}
			});
		});
	});
</script>
